import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution1313 {
    public int[] decompressRLElist(int[] nums) {
        List<Integer> list=new ArrayList<>();
        int i=0;
        while (i<nums.length){
            for (int j=0;j<nums[i];j++){
                list.add(nums[i+1]);
            }
            i+=2;
        }
        int[] ans=new int[list.size()];
        for (int j=0;j<list.size();j++){
            ans[j]=list.get(j);
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new Solution1313().decompressRLElist(new int[]{1, 2, 3, 4})));
    }
}
